# -*-coding: utf-8 -*-
# by zw on 2017/12/28


import asyncio_redis
from settings import config


class Redis:
    """
    A simple wrapper class that allows you to share a connection
    pool across your application.
    """
    _pool = None

    async def get_redis_pool(self):
        if not self._pool:
            self._pool = await asyncio_redis.Pool.create(
                host=config['redis_host'], port=config['redis_port'], poolsize=10
            )

        return self._pool


redis = Redis()
